"""
该脚本为cgai各类flag与状态流
"""
import os
from enum import Enum
from functools import wraps


def parm_input(*typelist):
    """
    传入参数类型列表
    :param typelist:
    :return:
    """

    def parm_filter(func):
        @wraps(func)
        def check_parm(*args, **kwargs):
            if args:
                for i in range(len(args)):
                    t = typelist[i]
                    p = args[i]
                    if not isinstance(p, t):
                        raise RuntimeError("错误的类型输入")
                ori_func = func(*args, **kwargs)
            return ori_func

        return check_parm

    return parm_filter


class CGAI(object):
    # 节点状态
    WAIT = 'Wait'
    RUNNING = 'Running'
    COMPLETED = 'Completed'
    ERROR = 'Error'

    # 状态颜色
    WAIT_COLOR = '#828282'
    RUNNING_COLOR = '#FF4500'
    COMPLETED_COLOR = '#00EE00'
    ERROR_COLOR = '#FF0000'

    # 连点端口
    LEFT = 0
    UP = 1
    RIGHT = 2
    DOWN = 3

    # 输入字体大小
    EDIT_FONT_SIZE = 12

    # 参数面板字体大小
    PARM_FONT_SIZE = 8
    PARM_LIST_FONT_SIZE = 18

    # 连接节点后计算数据方式
    NO_UPDATE = 0
    REALTIME_UPDATE = 1
    MOUSEUP_UPDATE = 2

    GPATH = os.path.dirname(__file__)
